﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StockFinder.Entities
{
    public class WeeklyPrice
    {
        public DailyPrice Monday { get; set; }
        public DailyPrice Tuesday { get; set; }
        public DailyPrice Wednesday { get; set; }
        public DailyPrice Thursday { get; set; }
        public DailyPrice Friday { get; set; }

        public int WeekOfYear { get; set; }
        public int Year { get; set; }

        public decimal GetWeeklyHigh()
        {
            decimal weeklyHigh = 0.0M;

            if (Monday != null)
            {
                weeklyHigh = Monday.High;
            }

            if (Tuesday != null)
            {
                if (Tuesday.High > weeklyHigh)
                {
                    weeklyHigh = Tuesday.High;
                }
            }

            if (Wednesday != null)
            {
                if (Wednesday.High > weeklyHigh)
                {
                    weeklyHigh = Wednesday.High;
                }
            }

            if (Thursday != null)
            {
                if (Thursday.High > weeklyHigh)
                {
                    weeklyHigh = Thursday.High;
                }
            }

            if (Friday != null)
            {
                if (Friday.High > weeklyHigh)
                {
                    weeklyHigh = Friday.High;
                }
            }

            return weeklyHigh;
        }

        public decimal GetWeeklyLow()
        {
            decimal weeklyLow = 0.0M;

            if (Monday != null)
            {
                weeklyLow = Monday.Low;
            }

            if (Tuesday != null)
            {
                if (Tuesday.Low < weeklyLow)
                {
                    weeklyLow = Tuesday.Low;
                }
            }

            if (Wednesday != null)
            {
                if (Wednesday.Low < weeklyLow)
                {
                    weeklyLow = Wednesday.Low;
                }
            }

            if (Thursday != null)
            {
                if (Thursday.Low < weeklyLow)
                {
                    weeklyLow = Thursday.Low;
                }
            }

            if (Friday != null)
            {
                if (Friday.Low < weeklyLow)
                {
                    weeklyLow = Friday.Low;
                }
            }

            return weeklyLow;
        }

        public decimal GetWeeklyOpen()
        {
            decimal weeklyOpen = 0.0M;

            if (Friday != null)
            {
                weeklyOpen = Friday.Open;
            }

            if (Thursday != null)
            {
                weeklyOpen = Thursday.Open;
            }

            if (Wednesday != null)
            {
                weeklyOpen = Wednesday.Open;
            }

            if (Tuesday != null)
            {
                weeklyOpen = Tuesday.Open;
            }

            if (Monday != null)
            {
                weeklyOpen = Monday.Open;
            }

            return weeklyOpen;
        }

        public decimal GetWeeklyClose()
        {
            decimal weeklyClose = 0.0M;

            if (Monday != null)
            {
                weeklyClose = Monday.Close;
            }

            if (Tuesday != null)
            {
                weeklyClose = Tuesday.Close;
            }

            if (Wednesday != null)
            {
                weeklyClose = Wednesday.Close;
            }

            if (Thursday != null)
            {
                weeklyClose = Thursday.Close;
            }

            if (Friday != null)
            {
                weeklyClose = Friday.Close;
            }

            return weeklyClose;
        }
    }
}
